package libra;

import java.time.Instant;
import java.time.LocalDateTime;
import java.util.Base64;

import org.junit.jupiter.api.Test;
import org.shredzone.acme4j.Account;
import org.shredzone.acme4j.AccountBuilder;
import org.shredzone.acme4j.Identifier;
import org.shredzone.acme4j.Order;
import org.shredzone.acme4j.Session;
import org.shredzone.acme4j.toolbox.TestUtils;

public class aaa {
	@Test
	public void test() throws Exception {
//		Session session = new Session("https://acme-staging-v02.api.letsencrypt.org/directory");
		Session session = new Session("http://127.0.0.1:8080/acme/directory");
		
		System.out.println( "\r\n\r\n\r\n\r\n创建用户");
		// 创建用户
		Account account = new AccountBuilder().addContact("mailto:274376645@qq.com")
				.useKeyPair(TestUtils.createKeyPair()).create(session);
		System.out.println( account.getStatus() );
		
		
		System.out.println( "\r\n\r\n\r\n\r\n创建订单");
		// 创建订单
//        var notBefore = parseTimestamp("2026-01-01T00:00:00+08");
//        var notAfter = parseTimestamp("2026-01-08T00:00:00+08:00");
		Order order = account.newOrder()
			//
//	        .domains("example.com", "www.example.com")
//	        .domain("example.org")
//	        .domains(Arrays.asList("m.example.com", "m.example.org"))
	        //
	        .identifier(
	        	Identifier.dns("www.bilibili.com")
	        )
//	        .identifiers(
//	        	Arrays.asList(
//                    Identifier.dns("d2.example.com"),
//                    Identifier.ip(InetAddress.getByName("192.0.2.2"))
//	        	)
//	        )
	        //
//	        .notBefore("2016-01-01T00:04:00+04:00")
//	        .notAfter("2016-01-08T00:04:00+04:00")
	        .create();
		System.out.println( order );
	}
}
